<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>整蛊宝典</title>
    <link rel="stylesheet" type="text/css" href="./aui.css"/>
    <link rel="stylesheet" href="mim-common-h5.css">
    <link rel="stylesheet" type="text/css" href="./swiper-bundle.min.css"/>
    <style>
        header {
            background: #409eff;
            color: #ffffff;
            padding: 30px;
            height: 100px;
            font-size: 20px;
        }

        .nav {
            width: 100%;
        }

        #swiper .swiper-slide {
            width: 100%;
        }

        .swiper-pagination {
            width: 100%;
        }

        .nav .swiper-pagination-bullet-active {
            border-radius: 0%;
            outline: none;
            width: 25%;
            height: 40px;
            opacity: 1;
            background: transparent;
            color: #ffffff;
            border-bottom: 3px solid #ffffff;
        }

        .nav .swiper-pagination-bullet {
            outline: none;
            background: transparent;
            width: 25%;
            height: 40px;
            opacity: 1;
            line-height: 40px;
            font-size: 14px;
        }

        .nav .swiper-pagination {
            width: 100%;
            background: rgb(81, 45, 168) !important;
            color: #ffffff;
            padding: 0 12px;
            height: 40px;
            font-size: 16px;
        }

        .cont {
            margin-top: 50px;
        }

        textarea::-webkit-input-placeholder {
            color: #b8c4ce !important;
        }

        textarea::-moz-placeholder {
            color: #b8c4ce !important;
        }

        textarea::-ms-input-placeholder {
            color: #b8c4ce !important;
        }

        .language-box {
            background-color: #ffffff;
            border-radius: 5px;
            width: 100%;
            margin: auto;
            height: 230px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04);
            padding: 12px;
        }

        #textarea, #textarea-rainbow, #textarea-dog, #textarea-chicken {
            width: 100%;
            font-size: 16px;
            height: 206px;
            outline: none;
            border: none;
            resize: none;
            color: #343434;
            overflow: auto;
            line-height: 24px;
        }

        .btn {
            font-size: 14px;
            color: #ffffff;
            background-color: #f56c6c;
            display: inline-block;
            width: 30%;
            height: 35px;
            line-height: 35px;
            border-radius: 5px;
            box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1)
        }

        h1 img {
            width: 32px;
            height: 32px;
            display: inline-block;
            vertical-align: middle;
        }

        h1 span {
            margin-left: 10px;
            display: inline-block;
            vertical-align: middle;
        }

        .nav .swiper-pagination-bullet:last-child {
            display: none;
        }

        .footer{
            position: fixed;
            bottom: 0;
            left: 0;
            width: 100%;
            font-size: 14px;
            padding: 5px 12px;
        }
        .footer span{
            font-size: 14px;
            color: #409EFF;
            float: left;
        }
        .contribute{
            font-size: 12px;
            position: absolute;
            top: 10px;
            right: 10px;
        }
        #cont {
            width: 100%;
            font-size: 14px;
            color: #343434;
            height: 120px;
            outline: none;
            resize: none;
            border: 1px solid #dcdfe6;
            padding: 15px;
            transition: border-color .2s cubic-bezier(.645, .045, .355, 1);
            vertical-align: middle;
            border-radius: 4px;
            margin-bottom: 10px;
        }
        textarea::-webkit-input-placeholder {
            color: #b8c4ce !important;
        }

        textarea::-moz-placeholder {
            color: #b8c4ce !important;
        }

        textarea::-ms-input-placeholder {
            color: #b8c4ce !important;
        }
        #message_board_btn {
            font-size: 12px;
            position: absolute;
            top: 10px;
            right: 80px;
        }
        .message_board_div{
            width: 100%;
            height: 86vh;
            border: 5px dashed #52d3bb;
            border-radius: 5px;
            position: relative;
        }
        .message_board{
            padding: 12px;
            height: calc(90vh - 160px);
            overflow: auto;
        }
        .message_board::-webkit-scrollbar {
            width: 1px;
            height: 1px;
            background-color: transparent;
        }

        .message_board::-webkit-scrollbar-thumb {
            cursor: pointer;
            border-radius: 1px;
            background-color: transparent;
        }
        .message_board .group{
            padding: 16px 0;
            border-bottom: 1px solid #f2f2f2;
        }
        .message_board .group:first-child{
            margin-top: -15px;
        }
        .message_board .group .floor{
            font-size: 12px;
            line-height: 20px;
            font-weight: 400;
            color: #aaaaaa;
        }
        .message_board .group .floor span{
            font-size: 12px;
            line-height: 20px;
            font-weight: 400;
            color: #7981A2;
            float: right;
        }
        .message_board .group .message{
            font-size: 14px;
            line-height: 24px;
            font-weight: 400;
            color: #343434;
            margin-top: 10px;
        }
        .send_message{
            position: absolute;
            bottom: 10px;
            right: 10px;
        }
        .load{
            text-align: center;
            font-size: 14px;
            line-height: 24px;
            font-weight: 400;
            color: #343434;
            padding: 12px;
            cursor: pointer;
        }

        #cont_message_board {
            font-size: 14px;
            color: #343434;
            height: 124px;
            outline: none;
            resize: none;
            border: 1px solid #dcdfe6;
            padding: 12px 12px 40px 12px;
            vertical-align: middle;
            border-radius: 4px;
        }


    </style>
</head>
<body>
<header>
    <h1 style="font-size: 20px"><img src="abuse.png" class="titleImge"><span id="spanid">骂人宝典</span><strong class="contribute" type="1">我要投稿</strong><strong id="message_board_btn">留言板</strong></h1>
</header>
<div class="nav">
    <div class="swiper-pagination"></div>
</div>
<div class="cont">
    <div class="swiper-container swiper-no-swiping" id="swiper" style="padding: 12px">
        <div class="swiper-wrapper">
            <div class="swiper-slide">
                <div class="language-box">
                    <textarea id="textarea" readonly></textarea>
                </div>
                <div style="width: 100%;text-align: center;margin-top: 20px">
                    <div class="btn" onclick="vitality()">火力全开</div>
                    <div class="btn" onClick="copyText('textarea')"
                         style="margin-left: 10px;background-color: #ffffff;color: #343434">复制
                    </div>
                </div>
            </div>
            <div class="swiper-slide">
                <div class="language-box">
                    <textarea id="textarea-rainbow" readonly></textarea>
                </div>
                <div style="width: 100%;text-align: center;margin-top: 20px">
                    <div class="btn" onclick="vitality()" style="background-color: #409eff">使劲夸</div>
                    <div class="btn" onClick="copyText('textarea-rainbow')"
                         style="margin-left: 10px;background-color: #ffffff;color: #343434">复制
                    </div>
                </div>
            </div>
            <div class="swiper-slide">
                <div class="language-box">
                    <textarea id="textarea-dog" readonly></textarea>
                </div>
                <div style="width: 100%;text-align: center;margin-top: 20px">
                    <div class="btn" onclick="vitality()" style="background-color:#e6a23c">接着舔</div>
                    <div class="btn" onClick="copyText('textarea-dog')"
                         style="margin-left: 10px;background-color: #ffffff;color: #343434">复制
                    </div>
                </div>
            </div>
            <div class="swiper-slide">
                <div class="language-box">
                    <textarea id="textarea-chicken" readonly></textarea>
                </div>
                <div style="width: 100%;text-align: center;margin-top: 20px">
                    <div class="btn" onclick="vitality()" style="background-color:#67C23A">再来一碗</div>
                    <div class="btn" onClick="copyText('textarea-chicken')"
                         style="margin-left: 10px;background-color: #ffffff;color: #343434">复制
                    </div>
                </div>
            </div>
            <div class="swiper-slide"></div>
        </div>
    </div>
</div>
<div class="footer">
    <span>作者：叶念安；QQ：1298025852</span>
    <span style="float: right;font-size: 16px;text-decoration: underline" onClick="goGiveMoney()">打赏一下</span>
</div>

<mim-drawer drawerTitle="投稿" direction="ttb" size="80%" class="mimDrawer">
    <mim-drawer-content>

        <div class="language-client">
            <div style="text-align: center;font-size: 18px;font-weight: bold;padding-bottom: 20px">我要投稿《<span class="typeHtml">骂人宝典</span>》</div>
            <label>
                <strong><i style="color: #f56c6c">*</i>您的名句:</strong>
                <textarea placeholder="请输入您的金口玉言,感谢您的支持^_^" id="cont"></textarea>
            </label>
            <label>
                <strong style="display: inline-block;width: 100%"><i style="color: #f56c6c;visibility: hidden">*</i>联系方式:</strong>
                <mim-input type="text" placeholder="可以留下您的联系方式吗？(选填)" style="width: 100%" id="phone"></mim-input>
            </label>
            <div style="text-align: center">
                <mim-button type="primary" size="medium" style="width: 50%;margin-top: 70px" id="submit">提交</mim-button>
            </div>
        </div>

    </mim-drawer-content>
</mim-drawer>

<mim-drawer drawerTitle="留言板" direction="ttb" size="100%" class="mimDrawer_board">
    <mim-drawer-content>
        <mim-row>
            <mim-col span="24">
                <div class="message_board_div">
                    <div class="message_board">
                        <div class="message_board_list">
                            <!--<div class="group">
                                <p class="floor">1楼<span>2020-11-22</span></p>
                                <p class="message">你妈的花内裤挂在树上被猩猩瞻仰，被太阳晒的发黄，被情夫抚摸，被你炫耀！</p>
                            </div>-->
                        </div>
                        <div class="load" onclick="loadMore()">点击加载更多</div>
                    </div>

                    <textarea placeholder="请输入您的留言" id="cont_message_board" maxlength="100"></textarea>
                    <mim-button type="primary" size="mini" class="send_message">留言发送</mim-button>
                </div>
            </mim-col>
        </mim-row>
    </mim-drawer-content>
</mim-drawer>

<script src="jquery-3.3.1.min.js"></script>
<script src="mim-common.js"></script>
<script src="swiper-bundle.min.js"></script>
<script>
    var url = "http://www.taoerhuo.top/nmsl/public/index.php/index/api/full_fire";
    var type="";
    var Page = 1,
        Size = '',
        hasMore = 1;
    init();
    sendMessageInit();
    new Swiper('#swiper', {
        pagination: {
            el: '.swiper-pagination',
            clickable: true,//分页是否能点击
            renderBullet: function (index, className) {
                switch (index) {
                    case 0:
                        text = '骂人宝典';
                        break;
                    case 1:
                        text = '彩虹屁';
                        break;
                    case 2:
                        text = '舔狗日记';
                        break;
                    case 3:
                        text = '毒鸡汤';
                        break;
                }
                return '<span class="' + className + '" type='+(Number(index)+Number(1))+'>' + text + '</span>';
            },
        },
        loop: true,//环路
        effect: 'cube',
        cubeEffect: {
            slideShadows: false,
            shadow: false,
            shadowOffset: 100,
            shadowScale: 0.6
        },
    });
    function sendMessageInit(){
        if (hasMore == 1){
            MIM.ajaxUtils('http://www.taoerhuo.top/nmsl/public/index.php/index/api/get_list', {
                page:Page
            }, 'true', 'post', 'json', function (data) {
                if (data.code == 200) {
                    var retData = data.data.ly_list;
                    Size = data.data.per_page;
                    if (retData.length !== 0) {
                        hasMore = retData.length < Size ? 2 : 1;
                        if (hasMore == 2) {
                            $('.load').show().html('数据加载完毕')
                        }else {
                            $('.load').show().html('点击加载更多')
                        }
                        var html = appendHtml(retData);
                        $('.message_board_list').append(html);
                        Page++;
                    } else {
                        hasMore = 2;
                        $('.load').show().html('暂时没有数据~');
                    }
                } else {
                    MIM.prompt(data.message, 'danger', 2000);
                }
            }, function (ret) {
                MIM.prompt('失败', 'danger', 2000);
            });
        }else {
            MIM.prompt('数据加载完毕', 'info', 2000);
        }

    }
    //切换
    $(".swiper-pagination").on("click", "span", function () {
        $("#spanid").html($(this).html());
        $(".typeHtml").html($(this).html());
        $(".contribute").attr("type",$(this).attr("type"));
        var titleImge = "";
        switch ($(this).html()) {
            case '骂人宝典':
                titleImge = 'abuse.png';
                url = 'http://www.taoerhuo.top/nmsl/public/index.php/index/api/full_fire';
                break;
            case '彩虹屁':
                titleImge = 'rainbow.png';
                url = 'http://www.taoerhuo.top/nmsl/public/index.php/index/api/rainbow';
                break;
            case '舔狗日记':
                titleImge = 'dog.png';
                url = 'http://www.taoerhuo.top/nmsl/public/index.php/index/api/dog';
                break;
            case '毒鸡汤':
                titleImge = 'chicken.png';
                url = 'http://www.taoerhuo.top/nmsl/public/index.php/index/api/soul';
                break;
        }
        $(".titleImge").attr("src", titleImge);
        init()
    });

    function init() {
        MIM.ajaxUtils(url, {}, 'true', 'post', 'json', function (data) {
            if (data.code == 200) {
                $("#textarea").val(data.data.content);
                $("#textarea-rainbow").val(data.data.content);
                $("#textarea-dog").val(data.data.content);
                $("#textarea-chicken").val(data.data.content);
            } else {
                MIM.prompt(data.message, 'danger', 2000);
            }
        }, function (ret) {
            MIM.prompt('失败', 'danger', 2000);
        });
    }

    //    点击复制
    function copyText(textarea) {
        var target = document.getElementById(textarea);
        target.select(); // 选中文本
        document.execCommand("Copy"); // 执行浏览器复制命令
        MIM.prompt('复制成功', 'success', 2000);
    }

    //  火力全开
    function vitality() {
        init();
    }
    //   去打赏
    function goGiveMoney() {
        window.location.href = 'http://pay.taoerhuo.top/'
    }

//  我要投稿
    $(".contribute").on("click",function () {
        type = $(this).attr("type");
    }).drawerInit("mimDrawer");

    //    提交信息
    $("#submit").on("click", function () {
        var cont = $("#cont").val();
        var phone = $("#phone").val();
        if (cont) {
            MIM.ajaxUtils('http://www.taoerhuo.top/nmsl/public/index.php/index/api/tou', {
                content: cont,
                touch: phone,
                type: type
            }, 'true', 'post', 'json', function (data) {
                if (data.code == 200) {
                    MIM.prompt(data.message, 'success', 2000);
                    $("#cont").val("");
                    $("#phone").val("")
                } else {
                    MIM.prompt('失败', 'danger', 2000);
                }
            }, function (ret) {
                MIM.prompt('失败', 'danger', 2000);
            });
        } else {
            MIM.prompt('请输入你的金口玉言', 'danger', 2000);
        }
    });

    //留言板
    $("#message_board_btn").on("click",function () {

    }).drawerInit("mimDrawer_board");
    //   页面渲染
    function appendHtml(ret) {
        var data = ret;
        var html = '';
        $.each(data, function (i, val) {
            html += '<div class="group">';
            html += '<p class="floor">'+val["liu_number"]+'<span>发布于：'+val["create_time"]+'</span></p>';
            html += '<p class="message">'+val["content"]+'</p>';
            html += '</div>';
        });
        return html;
    }
    //加载更多
    function loadMore() {
        sendMessageInit()
    }
    //发布留言
    $(".send_message").on("click",function () {
        var cont = $("#cont_message_board").val();
        if(cont){
            MIM.ajaxUtils('http://www.taoerhuo.top/nmsl/public/index.php/index/api/to_liuyan', {
                content: cont,
            }, 'true', 'post', 'json', function (data) {
                if (data.code == 200) {
                    $(".message_board_list").empty();
                    Page = 1;hasMore = 1;
                    sendMessageInit();
                    $("#cont_message_board").val("");
                    MIM.prompt('发表成功', 'success', 2000);
                } else {
                    MIM.prompt('失败', 'danger', 2000);
                    $("#cont_message_board").val("");
                }
            }, function (ret) {
                MIM.prompt('失败', 'danger', 2000);
            });
        }else {
            MIM.prompt('请输入你的留言', 'danger', 2000);
        }
    })

</script>
</body>
</html>
